package com.example.canvastouch2;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;

public class WidthView extends View {

	private int width = 0;
	private Paint p = null;
	
	public WidthView(Context context) {
		super(context);
		init();
	}

	public WidthView(Context context, AttributeSet attrs) {
		super(context, attrs);
		init();
	}

	public WidthView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		init();
	}

	private void init() {
		p = new Paint();
		p.setColor(Color.WHITE);
		p.setStyle(Paint.Style.FILL);
	}

	@Override
	protected void onDraw(Canvas canvas) {
		super.onDraw(canvas);
		
		float w = this.getWidth();
		float h = this.getHeight();
		canvas.drawCircle(w/2, h/2, width/2, p);
	}

	public void setWidth(int width) {
		this.width = width;
	}
}
